
import React from 'react';
import myTemplate from './app.rt';

class app extends React.Component {

    template = myTemplate;

    constructor(props) {
        super(props);
        this.state = {
            date: new Date(),
            show: true,
            nameList: [
                '周亚楠',
                '顾世豪',
                '段廷瑞'
            ],
        };
    }

    componentDidMount () {
        console.log('挂载');
        this.timerId = setInterval(() => {
            let nowShow = this.state.show;
            this.setState({
                date: new Date()
            });
            this.setState((prevState, props) => ({
                show: !(prevState.show)
            }));
        }, 1000);
    }

    componentWillUnmount () {
        console.log('卸载');
        clearInterval(this.timerId);
    }

    render () {
        return this.template();
    }
}

export default app;